<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>demo1</title>
</head>
<body>
<div id="example-2">
    <p v-if="show">Hello LZUGIS</p>
    <my-checkbox v-model="show"></my-checkbox>
</div>
<script src="vue.js"></script>
<script>
    Vue.component('my-checkbox', {
        model: {
            prop: 'checked',
            event: 'change'
        },
        props: {
            checked: Boolean,
            // 这样就允许拿 `value` 这个 prop 做其它事了
            value: String
        },
        template:"<p><input v-on:change='setShow(this)' type='checkbox'/><span>是否显示</span></p>",

    });
    var app = new Vue({
        el: '#example-2',
        data:{
            /*
                如果不定义price， 则会报如下错误
                [Vue warn]: Property or method "price" is not defined on the instance but referenced during render.
             */
            show: true
        },
        method:{
            setShow:function(obj){
                console.log(obj);
            }
        }
    })
</script>
</body>
</html>